﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ovvio.Business;
using Ovvio.Data;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using Ovvio.Web.Core;

namespace Ovvio.Web.Areas.Admin.Models
{
    public enum DiscountType
    {
        [Description("Percentage Rate")]
        Percentage = 0,
        [Description("Fixed Amount")]
        Fixed = 1
    }

    public class DiscountModel : BaseModel<Discount>
    {
        [ScaffoldColumn(false)]
        public int Id { get { return Entity.Id; } set { Entity.Id = value; } }
        
        [Required]
        [DisplayName("Discount")]
        public int Discount { get { return Entity.DiscountValue.HasValue ? Entity.DiscountValue.Value : 0; } set { Entity.DiscountValue = value; } }

        [UIHint("DiscountTypeUserControl")]
        public DiscountType Type { get { return (DiscountType)Entity.DiscountType; } set { Entity.DiscountType = (short)value; } }

        [Required]
        public string Description { get { return Entity.Description; } set { Entity.Description = value; } }

        [Required]
        [DisplayName("Details")]
        public string Details { get { return Entity.Details; } set { Entity.Details = value; } }
    }
}
